#九九乘法表

print("============================（使用for...in...循环）============================")
#----左下角----
for i in range(1,10):
    for j in range(1,i+1):
        print("{}*{}={:<4}".format(j,i,i*j),end=" ")
    print("")

print("="*80)

#----左上角----
for i in range(9,0,-1):
    for j in range(1,i+1):
        print("{}*{}={:<4}".format(j,i,i*j),end=" ")
    print("")

print("="*80)

#----右下角----
for i in range(1,10):
    for k in range(1,10-i):
        print(end="         ")
    for j in range(i,0,-1):
        print("{}*{}={:<4}".format(j,i,j*i),end=" ")
    print("")

print("="*80)

#----右上角----
for i in range(9,0,-1):
    for k in range(9,i,-1):
        print(end="         ")
    for j in range(i,0,-1):
        print("{}*{}={:<4}".format(j, i, i * j), end=" ")
    print("")

print("============================（使用while循环）============================")
#----左下角----
i = 1
while(i<10):
    j = 1
    while(j<i+1):
        print("{}*{}={:<4}".format(j,i,i*j),end=" ")
        j+=1
    print("")
    i+=1


print("="*80)

#----左上角----
i = 9
while(i>0):
    j = 1
    while(j<i+1):
        print("{}*{}={:<4}".format(j,i,i*j),end=" ")
        j+=1
    print("")
    i-=1

print("="*80)

#----右下角----
i = 1
while(i<10):
    k = 1
    while(k<10-i):
        print(end="         ")
        k+=1
    j = i
    while(j>0):
        print("{}*{}={:<4}".format(j,i,j*i),end=" ")
        j-=1
    print("")
    i+=1

print("="*80)

#----右上角----
i = 9
while(i>0):
    k = 9
    while(k>i):
        print(end="         ")
        k-=1
    j = i
    while(j>0):
        print("{}*{}={:<4}".format(j,i,i*j),end=" ")
        j-=1
    print("")
    i-=1
